<#--
    -ObjectMap
    -------------------------
    -OBJECT_CODE
    -OBJECT_CODE_UPPERCASE
    -OBJECT_CODE_LOWERCASE
    -OBJECT_CODE_BEAN_PATTERN
    -OBJECT_CODE_CAMLE_CASE

    -ObjectMap.attributesList
    -----------------------------------------
    -ATTRIBUTE_CODE
    -ATTRIBUTE_CODE_UPPERCASE
    -ATTRIBUTE_CODE_LOWERCASE
    -ATTRIBUTE_CODE_BEAN_PATTERN
    -ATTRIBUTE_CODE_CAMEL_CASE

    -ATTRIBUTE_CODE_DATATYPE
    -ATTRIBUTE_IS_PRIMARY_KEY
    -ATTRIBUTE_IS_FOREIGN_KEY
    

  
 -->
package ${SERVICE_PACKAGE}.${ObjectMap.OBJECT_CODE_BEAN_PATTERN};

import com.ats.feeder.model.entities.${ObjectMap.OBJECT_CODE_BEAN_PATTERN}.${ObjectMap.OBJECT_CODE_CAMLE_CASE};
import com.ats.feeder.model.entitymanagers.admin.${ObjectMap.OBJECT_CODE_BEAN_PATTERN}.${ObjectMap.OBJECT_CODE_CAMLE_CASE}FacadeLocal;
import com.ats.feeder.model.exceptions.common.*;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;


@Stateless
public class ${ObjectMap.OBJECT_CODE_CAMLE_CASE}Service implements ${ObjectMap.OBJECT_CODE_CAMLE_CASE}ServiceLocal {

    @EJB
    ${ObjectMap.OBJECT_CODE_CAMLE_CASE}FacadeLocal ${ObjectMap.OBJECT_CODE_BEAN_PATTERN}Facade;


<#assign argument = "">
<#assign argument2 = "">

<#list ObjectMap.attributesList   as  myList>
    <#if myList.FILTER_BY = "true">
        <#if myList.ATTRIBUTE_CODE_DATATYPE !="Other">
                   <#assign argument = argument + myList.ATTRIBUTE_CODE_DATATYPE>
        <#else>
                   <#assign argument = argument + myList.FIELD_DATA_TYPE>
        </#if>
                    <#assign argument = argument + " " + myList.ATTRIBUTE_CODE_BEAN_PATTERN>
                    <#assign argument2 = argument2 + myList.ATTRIBUTE_CODE_BEAN_PATTERN>
                   <#if myList_has_next>
                        <#assign argument = argument + ", ">
                        <#assign argument2 = argument2 + ", ">
                   </#if>
    </#if>
</#list>

  @Override
    public List<${ObjectMap.OBJECT_CODE_CAMLE_CASE}> getByCriterion${ObjectMap.OBJECT_CODE_CAMLE_CASE}(${argument}) {
        return ${ObjectMap.OBJECT_CODE_BEAN_PATTERN}Facade.find${ObjectMap.OBJECT_CODE_CAMLE_CASE}ByCriterion(${argument2});
          
    }

 <#if ObjectMap.EM_HAS_INSERT ="true">
    @Override
    public ${ObjectMap.OBJECT_CODE_CAMLE_CASE} create${ObjectMap.OBJECT_CODE_CAMLE_CASE}(${ObjectMap.OBJECT_CODE_CAMLE_CASE} ${ObjectMap.OBJECT_CODE_BEAN_PATTERN}) throws CreateEntityException {
        try {
            return ${ObjectMap.OBJECT_CODE_BEAN_PATTERN}Facade.create(${ObjectMap.OBJECT_CODE_BEAN_PATTERN});
        } catch (CreateEntityException ex) {
            throw ex;
        }
    }
</#if>
 <#if ObjectMap.EM_HAS_UPDATE ="true">
    @Override
    public ${ObjectMap.OBJECT_CODE_CAMLE_CASE} update${ObjectMap.OBJECT_CODE_CAMLE_CASE}(${ObjectMap.OBJECT_CODE_CAMLE_CASE} ${ObjectMap.OBJECT_CODE_BEAN_PATTERN}) throws UpdateEntityException {
        try {
            return ${ObjectMap.OBJECT_CODE_BEAN_PATTERN}Facade.edit(${ObjectMap.OBJECT_CODE_BEAN_PATTERN});
        } catch (UpdateEntityException ex) {
            throw ex;
        }
    }
</#if>

 <#if ObjectMap.EM_HAS_DELETE ="true">
    @Override
    public boolean delete${ObjectMap.OBJECT_CODE_CAMLE_CASE}(${ObjectMap.OBJECT_CODE_CAMLE_CASE} ${ObjectMap.OBJECT_CODE_BEAN_PATTERN}) throws DeleteEntityException {
        try {
            return ${ObjectMap.OBJECT_CODE_BEAN_PATTERN}Facade.delete(${ObjectMap.OBJECT_CODE_BEAN_PATTERN});
        } catch (DeleteEntityException ex) {
            throw ex;
        }
    }
</#if>

}
